package com.wzcl.app.controller;

import com.wzcl.app.dao.model.EssayCourseQuestionBank;
import com.wzcl.app.model.common.RVO;
import com.wzcl.app.model.dto.EssayCourseQuestionBankDto;
import com.wzcl.app.service.EssayCourseQuestionBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author beingven
 * @Description TODO
 * @createTime 2020年12月25日 16:26:00
 */
@RestController
@RequestMapping("/questionBank")
@Api(value = "作文课题库Controller", tags = {"作文课题库Controller"})
public class EssayCourseQuestionBankController {
    @Resource
    private EssayCourseQuestionBankService essayCourseQuestionBankService;

    @PostMapping("/retrieve/all")
    @ApiOperation("导入题库")
    public RVO importQuestionBank(@RequestBody List<EssayCourseQuestionBank> questionBanks){
        return RVO.success(essayCourseQuestionBankService.importQuestionBank(questionBanks));
    }

    @DeleteMapping("/delete/many")
    @ApiOperation("批量删除题库")
    public RVO deleteByIds(@RequestBody List<Integer> ids){
        return essayCourseQuestionBankService.deleteByIds(ids);
    }

    @DeleteMapping("/delete/all")
    @ApiOperation("清空题库")
    public RVO deleteAll(){
        return essayCourseQuestionBankService.deleteAll();
    }

    @PostMapping("/retrieveAll/page")
    public RVO retrieveAllByPage(EssayCourseQuestionBankDto questionBankDto){
        return RVO.success(essayCourseQuestionBankService.retrieveAllByPage(questionBankDto));
    }
}